package net.batkin.poppler.document;

import java.util.Set;

import net.batkin.poppler.page.Page;

public class Document {

	static {
		System.loadLibrary( "popplerjambi" );
	}

	@SuppressWarnings( "unused" )
	private long _documentHandle;

	private Document( long documentHandle ) {
		this._documentHandle = documentHandle;
	}

	public native static Set<RenderBackend> availableRenderBackends();

	public native static Document load( String filePath, String ownerPassword, String userPassword );

	public native static Document loadFromData( byte[] fileContents, String ownerPassword, String userPassword );

	public native void setRenderBackend( RenderBackend backend );

	public native void setRenderHint( RenderHint hint, boolean on );

	public native Page page( String label );

	public native Page page( int index );

	public native int numPages();

	public native boolean isLocked();

	private native void cleanupDocument();

	@Override
	protected void finalize() throws Throwable {
		cleanupDocument();
	}
}
